package com.woniu.humanresource.service.impl;

import com.woniu.humanresource.dao.DepartureDao;
import com.woniu.humanresource.dao.DepartureImgDao;
import com.woniu.humanresource.entity.Departure;
import com.woniu.humanresource.entity.DepartureImg;
import com.woniu.humanresource.entity.PageBean;
import com.woniu.humanresource.service.DepartureService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class DepartureServiceImpl implements DepartureService {
    @Resource
    DepartureDao departureDao;
    @Resource
    DepartureImgDao departureImgDao;

    @Override
    public void insertDeparture(Departure departure) {
        departureDao.insertDeparture(departure);
    }



    @Override
    public PageBean<Departure> selectCondition(Departure departure, int pageIndex, int pageSize) {
        //        查询离职信息列表
        List<Departure> departures = departureDao.selectCondition(departure, pageIndex, pageSize);
        //        封装为PageBean对象，并设置属性
        PageBean<Departure> pageBean=new PageBean<>();
        pageBean.setBeanList(departures);
        pageBean.setPageSize(pageSize);
        pageBean.setPageIndex(pageIndex);
        pageBean.setBeginEnd();
        pageBean.setTotalRecord(selectConditionCount(departure));
        return pageBean;
    }

    @Override
    public int selectConditionCount(Departure departure) {
        int count = departureDao.selectConditionCount(departure);
        return count;
    }

    @Override
    public void deleteDeparture(int id) {
        departureDao.deleteDeparture(id);
    }

    @Override
    public void updateDeparture(Departure departure) {
        departureDao.updateDeparture(departure);
    }

    @Override
    public void insertDepartureImg(DepartureImg departureImg) {
        departureImgDao.insertDepartureImg(departureImg);
    }

    @Override
    public void deleteDepartureImg(int id) {
        departureImgDao.deleteDepartureImg(id);
    }
}
